<?php

namespace app\queue\Order;
use app\service\OrderProfitService;
use support\facade\Logger;
use Webman\RedisQueue\Consumer;
use const support\AUTO_HANDLE_ORDER_PROFIT_QUEUE;

class OrderProfitHandle implements Consumer
{
    // 要消费的队列名
    public $queue = AUTO_HANDLE_ORDER_PROFIT_QUEUE;

    // 连接名
    public $connection = 'default';

    // 消费
    public function consume($data): bool
    {
        Logger::app('分账订单队列:开始','info',$data);
        try {
            return OrderProfitService::setProfitDivider($data['order_id']);
        }catch (\Throwable $e){
            Logger::app('分账订单队列:异常','info',[$e->getMessage()]);
            return false;
        }
    }
}